/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.dotexe.webframework.core.communication;

import org.json.JSONException;
import org.json.JSONObject;

import com.dotexe.webframework.core.ClientApplication;

/**
 *
 * @author jovan.tomasevic
 * complete
 */
public class ErrorMessage extends JSONObject {
    public ErrorMessage() throws JSONException
    {
        this.append("Text", "");
        this.append("Caption", "");
        this.append("Critical", false);
        this.append("ExceptionType", "");
            //this.Caption = "Error";
            //this.Critical = false;
    }
    public String getText() throws JSONException{
        return this.getString("Text");
    }
    public void setText(String value) throws JSONException{
        if(value == null){
            this.put("Text", JSONObject.NULL);
        }
        else{
            this.put("Text", value);
        }
    }
    public String getCaption() throws JSONException{
        return this.getString("Caption");
    }
    public void setCaption(String value) throws JSONException{
        if(value == null){
            this.put("Caption", JSONObject.NULL);
        }
        else{
            this.put("Caption", value);
        }
    }
    public Boolean getCritical() throws JSONException{
        return this.getBoolean("Critical");
    }
    public void setCritical(Boolean value) throws JSONException{
        if(value == null){
            this.put("Critical", JSONObject.NULL);
        }
        else{
            this.put("Critical", value);
        }
    }
    public String getExceptionType() throws JSONException{
        return this.getString("ExceptionType");
    }
    public void setExceptionType(String value) throws JSONException{
        if(value == null){
            this.put("ExceptionType", JSONObject.NULL);
        }
        else{
            this.put("ExceptionType", value);
        }
    }
    public static void Show(ClientApplication context, String caption, String message) throws JSONException{
        ErrorMessage m = new ErrorMessage();
        m.setCaption("Error");
        m.setText(message);
        context.getResponse().setError(m);
    }
    /**
    public String Text ;
    public String Caption ;
    public Boolean Critical ;
    public String ExceptionType ;
     */
}
